function [A1 A2 B11 B12 B21 B22 m] = loadMatrix(n,N)

t = [0:1/N:n-1]';
t1 = t(1:length(t)-1);
t2 = t(2:length(t));
m = length(t1);

% i corresponds to i'th arc
i1 = floor(t1+eps); 
i2 = floor(t2+eps); % not really used. use i1 since line segment should be part of same arc

% indexes in matlab start from 1
ind1 = int8(i1)+1;
ind2 = int8(i2)+1; % again, not really used


A1 = 2*(i1+1-t1).*(t1-i1);
A2 = 2*(i1+1-t2).*(t2-i1);
B11 = ((i1+1-t1).^2)*ones(1,3);
B12 = ((t1-i1).^2)*ones(1,3);
B21 = ((i1+1-t2).^2)*ones(1,3);
B22 = ((t2-i1).^2)*ones(1,3);

end